﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections.Specialized;
using OSGeo.MapGuide;


namespace NegevGas.Extensions.markup
{
    public partial class newmarkup : utilityfunctions
    {
        public String errorMsg = null;
        public String errorDetail = null;
        public bool projectManagerAllowed;
        public NameValueCollection args = null;
        public List<string> projects = new List<string>();
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                args = GetRequestParameters();
                //LayoutModulesConfiguration config = new LayoutModulesConfiguration(Request["LAYOUT"]);
                /* ModuleConfig moduleConfig = config.GetProperties("ProjectManager");
                 projectManagerAllowed = (bool)moduleConfig["AllowProjectManager"].Value;
                 //projectManagerAllowed = true;
                 if(projectManagerAllowed)
                 {
                     using (var conn = new System.Data.SqlClient.SqlConnection(ConfigurationManager.ConnectionStrings["ProjectManagerConnectionString"].ConnectionString))
                     {
                         var cmd = conn.CreateCommand();
                         cmd.CommandText = "SELECT DISTINCT ProjectCollectionName FROM ProjectCollections WHERE LayoutId=@LayoutId";
                         cmd.CommandType = System.Data.CommandType.Text;
                         var layoutIdParam = new System.Data.SqlClient.SqlParameter("@LayoutId", System.Data.SqlDbType.NVarChar, 255);
                         layoutIdParam.Value = Request["LAYOUT"];
                         cmd.Parameters.Add(layoutIdParam);
                         conn.Open();
                         using (var reader = cmd.ExecuteReader())
                         {
                             while (reader.Read())
                             {
                                 projects.Add(reader["ProjectCollectionName"].ToString());
                             }
                         }
                         conn.Close();
                     }
                 }*/
            }
            catch (MgException eee)
            {
                errorMsg = eee.GetExceptionMessage();
                errorDetail = eee.GetDetails();
            }

        }
    }
}